FROM ubuntu:20.04

ENV AWS_ACCESS_KEY_ID test
ENV AWS_SECRET_ACCESS_KEY test
ENV S3_BUCKET_NAME test

RUN apt-get update && \
    apt-get -y install software-properties-common && \
    apt-get -y install python3.8 && \
    apt-get -y install python3-pip && \
    apt-get -y install curl && \
    apt-get -y install sudo

RUN pip3 install awscli && \
    pip3 install checkov && \
    apt-get -y install wget && \
    apt-get install unzip && \
    pip3 install dataclasses

RUN curl -L https://github.com/cloudskiff/driftctl/releases/latest/download/driftctl_linux_amd64 -o driftctl
RUN chmod +x driftctl
RUN mv driftctl /usr/bin/driftctl

#  get terraform 0.12.31
RUN wget https://releases.hashicorp.com/terraform/0.12.31/terraform_0.12.31_linux_amd64.zip
RUN unzip terraform_0.12.31_linux_amd64.zip && rm terraform_0.12.31_linux_amd64.zip
RUN mv terraform /usr/bin/terraform

RUN driftctl version
RUN terraform -v
RUN checkov -v

# get terraformer
RUN wget https://github.com/GoogleCloudPlatform/terraformer/releases/download/0.8.13/terraformer-aws-linux-amd64
RUN chmod +x terraformer-aws-linux-amd64
RUN mv terraformer-aws-linux-amd64 /usr/bin/terraformer

RUN terraformer -v

COPY ./versions.tf ./

RUN mkdir -p /scripts

ADD ./process.sh /scripts
RUN chmod +x /scripts/process.sh

#CMD ["/process.sh"]
CMD ["/scripts/process.sh","${AWS_ACCESS_KEY_ID}","${AWS_SECRET_ACCESS_KEY}","${S3_BUCKET_NAME}"]

